extends CharacterBody2D

@export var speed = 10000
@export var joy_stick: TouchScreenButton
@onready var animated: AnimatedSprite2D = $Animated

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	pass

func _physics_process(delta):
	var val = Vector2.ZERO
	if Input.is_action_pressed("walk_up"):
		val.y-=1
	if Input.is_action_pressed("walk_down"):
		val.y+=1
	if Input.is_action_pressed("walk_left"):
		val.x-=1
	if Input.is_action_pressed("walk_right"):
		val.x+=1
	
	if val.length()>0:
		val.normalized()
		animated.play("walk")
	else:
		animated.pause()

	velocity = val * delta * speed
	move_and_slide()
